﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using zhangmenren.Models;
using zhangmenren.Untils;

// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace zhangmenren.Areas.Admin.Controllers
{
    public class ABaseController : Controller
	{
		/// <summary>
		/// 方法执行前执行
		/// </summary>
		/// <param name="filterContext"></param>
		public override void OnActionExecuting(ActionExecutingContext filterContext)
		{
			var entity = Cookie.GetCookie<AdminEntity>(Request.HttpContext);

			if (entity?.Id == null)
			{
				filterContext.Result = Redirect("/Admin/Login/Index");
			}

			base.OnActionExecuting(filterContext);//执行完拦截后执行原方法
		}

	}
}
